////
//
/// \file ./include/inc/parser/expression_node.hpp
//
//  Copyright 2007, 2008 Chandler Carruth
//
//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
//  use this file except in compliance with the License.  You may obtain a copy
//  of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
//  License for the specific language governing permissions and limitations
//  under the License.
//
////

#ifndef inc_parser_expression_node_header
#define inc_parser_expression_node_header

#include <string>

#include <boost/scoped_ptr.hpp>

#include <inc/parser/parse_tree_node.hpp>
#include <inc/parser/ws_parser.hpp>

namespace inc {
namespace parser {

class NameNode;
class FunctionCallNode;
class ImmediateNode;
class OperationNode;

/// \brief  Expression Node
/// \author Chandler Carruth
/// \date   2007.06.2
///
/// This parses expressions in INC. The expressions form a major part of the
/// language, and a primary point of recursion through the context free
/// grammar. This is an extremely important node to get correct and fast as
/// a large portion of the parsing of the language will take place here.

class ExpressionNode : public ParseTreeNode
{
public:
  ExpressionNode() : self_reference( false ) {}

  virtual bool parse( const iterator& first,
                      const iterator& last,
                      iterator& last_parsed );

  virtual bool is_self() const { return self_reference; }

  virtual NameNode* get_name() const;
  virtual bool is_name() const { return get_name() != NULL; }

  virtual ImmediateNode* get_immediate() const;
  virtual bool is_immediate() const { return get_immediate() != NULL; }

  virtual FunctionCallNode* get_function_call() const;
  virtual bool is_function_call() const { return get_function_call() != NULL; }

  virtual OperationNode* get_operation() const;
  virtual bool is_operation() const { return get_operation() != NULL; }

private:
  bool self_reference;
  boost::scoped_ptr<ParseTreeNode> node;
};

} //  end parser namespace
} //  end inc namespace
#endif  //  inc_parser_expression_node_header
